-
Notifications
You must be signed in to change notification settings - Fork 471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isset()
narrows string-key in int-keyed-array to numeric-string
#3472
Conversation
You've opened the pull request against the latest branch 2.0.x. PHPStan 2.0 is not going to be released for months. If your code is relevant on 1.12.x and you want it to be released sooner, please rebase your pull request and change its target to 1.12.x. |
); | ||
} | ||
|
||
$narrowedKey = AllowedArrayKeysTypes::narrowOffsetKeyType($varType, $dimType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as a first step I think its easier to have a static method for this.
after we get more similar with the array_key_exists
impl we will see whether it makes sense to move this method into the ConstantScalarType
-interface, as we discussed in dresden
assertType('int', $i); | ||
} else { | ||
assertType('int', $i); | ||
} | ||
assertType('int', $i); | ||
|
||
if (isset($arr[$s])) { | ||
if (isset($intKeyedArr[$s])) { | ||
assertType('numeric-string', $s); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this assertion is the interessting one, which got more precise with this PR
-> it seems to be caused by some github infrastructure thing -> works again |
afcd618
to
532858f
Compare
This pull request has been marked as ready for review. |
5a57c75
to
fde07b5
Compare
fde07b5
to
2f2e842
Compare
Thank you! |
initial steps to make
isset()
implementation even more similar toarray_key_exists
so we can in the end hopefully share the implementationcommit 1: plain 1:1 refactoring, no implementation changes
commit 2: the fix as the PR topic suggests